//
//  AmuseViewController.swift
//  DouYuZB
//
//  Created by 刘耀 on 2017/4/14.
//  Copyright © 2017年 深圳多诺信息科技有限公司. All rights reserved.
//

import UIKit

private let kMunuViewH: CGFloat = 200

/// 娱乐界面
class AmuseViewController: BaseAnchorViewController {

    // MARK: - 懒加载
    fileprivate lazy var amuseVM : AmuseViewModel = AmuseViewModel()
    fileprivate lazy var menuVIew: AmuseMenuView = {
       let munuView = AmuseMenuView.amuseMenuView()
        munuView.frame = CGRect(0, -kMenuViewH, kScreenW, kMenuViewH)
        return munuView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
}

extension AmuseViewController {
    override func setupUI() {
         super.setupUI()
        collectionView.addSubview(menuVIew)
        collectionView.contentInset = UIEdgeInsets(top: kMunuViewH, left: 0, bottom: 0, right: 0)
    }
}


// MARK: - 请求数据
extension AmuseViewController {
    override func loadData() {
        // 请求推荐数据 没有循环引用。对象没有对闭包强引用
        // 2.请求数据
        baseVM = amuseVM
        amuseVM.loadAmuseData {
            // 2.1.刷新表格
            self.collectionView.reloadData()
            
            var tempGroups = self.amuseVM.anchorGroups
            tempGroups.removeFirst()
            self.menuVIew.groups = tempGroups
            self.loadDataFinished()
        }

    }
}


